﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Common;
using DataAccess;
using System.Drawing;
using System.Text;
using System.Configuration;
using System.Data.SqlClient;

public partial class Manager_Default : System.Web.UI.Page
{
    DataTable table;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Message"] != null)
        {
            lblmes.Text = Session["Message"].ToString();
            Session.Remove("Message");
        }
        else
            lblmes.Text = "";
    }
    private void DataBind()
    {
        DbCommand cmd = GenericData.CreateCommand();
        cmd.CommandText = "SELECT * FROM Candidate";
        table = GenericData.ExecuteReader(cmd);
       // grvCandidate.DataSource = table;
       // grvCandidate.DataBind();
    }

 
   /*
    protected void grvCandidate_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex < 0)
            return;
        if (e.Row.RowIndex != grvCandidate.EditIndex)
        {

            e.Row.Cells[6].Attributes.Add("onclick", "return confirm('Delete candidate ?')");
        }
    }
    protected void grvCandidate_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grvCandidate.PageIndex = e.NewPageIndex;
        load();
    }
    protected void grvCandidate_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            int id = int.Parse(grvCandidate.DataKeys[e.RowIndex].Value.ToString());
            SqlConnection con = new SqlConnection(_connStr);
            con.Open();
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandText = "Delete from Candidate where ID = @ID";
            cmd.Parameters.Add("@ID", SqlDbType.Int).Value = id;
            cmd.ExecuteNonQuery();
            Response.Write("<scrip> alert('Ok')</scrip>");
            load();
        }
        catch (Exception ex)
        {

            Response.Write(ex.Message);
        }
    }*/
}